package com.iotimc.attendancesystem.entity;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.ToOne;

import java.util.Date;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.DaoException;
import com.iotimc.attendancesystem.dao.DaoSession;
import com.iotimc.attendancesystem.dao.PersonEntityDao;
import org.greenrobot.greendao.annotation.NotNull;
import com.iotimc.attendancesystem.dao.DoorLogEntityDao;

/**
 *
 * @author david
 * @date 2017/11/28
 */
@Entity
public class DoorLogEntity {
    @Id(autoincrement = true)
    private Long id;
    private String personId;
    @ToOne(joinProperty = "personId")
    private PersonEntity personEntity;
    private Date createTime;
    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;
    /** Used for active entity operations. */
    @Generated(hash = 924286702)
    private transient DoorLogEntityDao myDao;
    @Generated(hash = 1995989915)
    public DoorLogEntity(Long id, String personId, Date createTime) {
        this.id = id;
        this.personId = personId;
        this.createTime = createTime;
    }
    @Generated(hash = 296255813)
    public DoorLogEntity() {
    }
    public Long getId() {
        return this.id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getPersonId() {
        return this.personId;
    }
    public void setPersonId(String personId) {
        this.personId = personId;
    }
    public Date getCreateTime() {
        return this.createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Generated(hash = 810602909)
    private transient String personEntity__resolvedKey;
    /** To-one relationship, resolved on first access. */
    @Generated(hash = 1840604545)
    public PersonEntity getPersonEntity() {
        String __key = this.personId;
        if (personEntity__resolvedKey == null
                || personEntity__resolvedKey != __key) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            PersonEntityDao targetDao = daoSession.getPersonEntityDao();
            PersonEntity personEntityNew = targetDao.load(__key);
            synchronized (this) {
                personEntity = personEntityNew;
                personEntity__resolvedKey = __key;
            }
        }
        return personEntity;
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 629359072)
    public void setPersonEntity(PersonEntity personEntity) {
        synchronized (this) {
            this.personEntity = personEntity;
            personId = personEntity == null ? null : personEntity.getId();
            personEntity__resolvedKey = personId;
        }
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 377035221)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getDoorLogEntityDao() : null;
    }
   
}
